<template>
	<div style="background-color: #fff;" id="loginDiv">
		<div>
		<mu-appbar title="登录" @click="login" class="example-appbar">
	 	</mu-appbar>
    <!--<mu-appbar/>-->
	 	<div class="login-form">
			<mu-text-field label="用户名" hintText="请输入账号" v-model="username" labelFloat/><br/>
		  	<mu-text-field label="密码" hintText="请输入密码" v-model="password" type="password" labelFloat/><br/>
		    <mu-raised-button label="登录" @click="login" class="demo-raised-button" fullWidth primary/>
    	</div>
    	</div>
       <div id="login_container" style="width:200px;height:500px"></div>
	</div>
</template>
<script>

import * as types from './store/types'
export default {
 	name: '',
    data () {
      return {
        username:'',
        password:'',
        token: null
      }
    },
    mounted(){
      let that=this
//  	that.$parent.isLogin=false
    	that.$parent.isBotNav=false
    	that.$parent.isTopNav=false
    	this.getTarHeight()
    },
    methods: {
      	login(){
      		let that = this
      		that.axios.post('/gleenSoft-base/login_login',{username:that.username,password:that.password}).then(function (response) {
            if(response.data.result=='身份验证'){
              that.$parent.showToast(response.data.result)
            }else{
              
              that.token = response.data.token
              let identity=(that.username.length==12)?'Student':'Teacher';
              that.$parent.userIdentity = identity
              that.$parent.isCommissary = response.data.user_info.C_GROUPID!=null
              that.$parent.userInfo = response.data.user_info
//            that.$parent.isLogin = true
              that.$parent.isBotNav= true
              console.info(that)
              that.$store.commit(types.LOGIN, that.token)
	          	let redirect = decodeURIComponent(that.$route.query.redirect || '/');
	          	that.$router.push({
	            	path: redirect
	          	})
            }
  	       })
      	},
    }
}
</script>
<style >
 .login-form{
    width: 100%;
    padding: 40px;
    text-align: center;

  }
  .login-form .mu-text-field{
    width:100%;
  }
</style>